﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ChatApp
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void LoginUser(object sender, EventArgs e)
        {
            DBConnection.TwitterDataContext db = new DBConnection.TwitterDataContext();

            string userID = UserIDLoginTextBox.Text;
            string userPwd = UserPasswordLoginTextBox.Text;

            if (
                DBConnection.UsersDAO.IsCorrectLogin(userID, userPwd, db)
            )
            {
                Session["userID"] = UserIDLoginTextBox.Text;
                Response.Redirect("Chat.aspx");
            }
            else
            {
                LoginResultLabel.Text = "Invalid user/password!";
            }
        }
    }
}
